package edu.zju.gis.dldsj.service.impl;

import edu.zju.gis.dldsj.dao.UserFavoriteMapper;
import edu.zju.gis.dldsj.entity.UserFavorite;
import edu.zju.gis.dldsj.service.UserFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanlo yanlong_lee@qq.com
 * @version 1.0 2018/08/09
 */
@Service
public class UserFavoriteServiceImpl implements UserFavoriteService {
    @Autowired
    private UserFavoriteMapper userFavoriteMapper;

    @Override
    public UserFavorite select(String pk) {
        return userFavoriteMapper.selectByPrimaryKey(pk);
    }

    @Override
    public int insert(UserFavorite userFavorite) {
        return userFavoriteMapper.insertSelective(userFavorite);
    }

    @Override
    public void update(UserFavorite userFavorite) {
        userFavoriteMapper.updateByPrimaryKeySelective(userFavorite);
    }

    @Override
    public void delete(String s) {
        userFavoriteMapper.deleteByPrimaryKey(s);
    }

    @Override
    public boolean isExist(String s) {
        return userFavoriteMapper.selectByPrimaryKey(s) != null;
    }

    @Override
    public List<UserFavorite> getByPage(int offset, int size) {
        return userFavoriteMapper.selectByPage(offset, size);
    }

    @Override
    public void deleteByDataId(String userId, String dataId, String dataType) {
        userFavoriteMapper.deleteByDataId(userId, dataId, dataType);
    }
}
